import java.util.*;


public class Text {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param A string字符串 
     * @return int整型
     */
    public static int getLongestPalindrome (String A) {
        // write code here
        if(A == null) return 0;
        if(A.length() == 1) return 1;
        int max = 0;
        for (int i = 0; i < A.length(); i++) {
            int len1 = Search(A,i,i);
            int len2 = Search(A,i,i+1);
            max = Math.max(Math.max(len1,len2),max);
        }
        return max;
    }

    private static int Search(String a, int left, int right) {
        while((left >= 0 && right < a.length()) && a.charAt(left) == a.charAt(right)){
            left -- ;
            right ++;
        }
        return right - left - 1;
    }

    public static void main(String[] args) {
        String ret = "ababc";
        System.out.println(getLongestPalindrome(ret));
    }
}